﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Options.IBClient.Component
{
     [Serializable()]
    public class Security : IComparable<Security>
    {
        #region Private Variables
         //main security fields
         private  int id;
         private string symbol;
         private  string definition;
         private bool isWeekly;
        #endregion

        #region Constructor
        /// <summary>
        /// Default Constructor
        /// </summary>
         public Security()
         {
             symbol = string.Empty;
             definition = string.Empty;
             isWeekly = false;
         }
        #endregion

        #region Properties
         public int SecurityId
         {
             get { return id; }
             set { id = value; }
         }

         public string Symbol
         {
             get { return symbol; }
             set { symbol = value; }
         }

         public string Definition
         {
             get { return definition; }
             set { definition = value; }
         }

         public bool IsWeekly
         {
             get { return isWeekly; }
             set { isWeekly = value; }
         }


         public override bool Equals(object obj)
         {
             if (obj == null) return false;
             Security objAsPart = obj as Security;
             if (objAsPart == null) return false;
             else return Equals(objAsPart);
         }
        
         // Default comparer for Security type. 
         public int CompareTo(Security compareSymbol)
         {
             // A null value means that this object is greater. 
             if (compareSymbol == null)
                 return 1;

             else
                 return this.Symbol.CompareTo(compareSymbol.Symbol);
         }

         public bool Equals(Security other)
         {
             if (other == null) return false;
             return (this.Symbol.Equals(other.Symbol));
         }
        // Should also override == and != operators.
        #endregion
    }
}
